home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / NGService / MMGraphicCell.m < prev    next >
Encoding:
Text File  |  1992-08-10  |  1.2 KB  |  61 lines

  1. /*
  2.  *      You may freely copy, distribute and reuse the code
  3.  *      in this example.  Scott Anguish disclaims any warranty of
  4.  *      any kind, expressed or implied, as to its fitness
  5.  *      for any particular use.
  6.  *        Please keep this notice intact
  7.  *      Written by: Scott Anguish  sanguish@digifix.com
  8.  */
  9.  
  10. #import "MMGraphicCell.h"
  11.  
  12. #import <libc.h>                      /* MAXPATHLEN */
  13. #import <stdio.h>
  14. #import <strings.h>
  15.  
  16. #import <appkit/appkit.h>
  17.  
  18. #import <streams/streams.h>
  19.  
  20.  
  21. @implementation MMGraphicCell:MMCell
  22.  
  23. - imageFromFilename:(const char *)filename
  24. {
  25.     
  26.     theImage =[[NXImage alloc] initFromFile:filename];
  27.     return self;
  28. }
  29.  
  30. - imageFromAttachment
  31. {
  32.     char filename[MAXPATHLEN+1];
  33.  
  34.     sprintf(filename,"/tmp/%s",attachmentName);
  35.     [self imageFromFilename:filename];
  36.     return self;
  37. }
  38.  
  39.  
  40. - uudecodeAttachment
  41. {
  42.     FILE *fp;
  43.     char commandStr[BUFSIZ];
  44.     
  45.     sprintf(commandStr,"rm -f /tmp/%s; /usr/bin/uudecode ",attachmentName);
  46.     fp = popen (commandStr,"w");
  47.     if (fp != (FILE *)NULL)
  48.         {
  49.         fprintf(fp,"begin 644 /tmp/%s\n",attachmentName);
  50.         fwrite(attachmentData,sizeof(char),attachmentSize,fp);
  51.         fprintf(fp,"end\n");
  52.         fprintf(stderr,"Pipe Result %d \n",pclose(fp));
  53.         }
  54.         else
  55.         fprintf(stderr,"Pipe did not open \n");
  56.     return self;
  57. };
  58.  
  59.  
  60. @end
  61.